/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.agenda.model.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ronildo
 */
@Entity
@Table(name = "AM_TB_CIDA")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AmTbCida.findAll", query = "SELECT a FROM AmTbCida a"),
    @NamedQuery(name = "AmTbCida.findByCdCida", query = "SELECT a FROM AmTbCida a WHERE a.cdCida = :cdCida"),
    @NamedQuery(name = "AmTbCida.findByNmCida", query = "SELECT a FROM AmTbCida a WHERE a.nmCida = :nmCida")})
public class AmTbCida implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @Basic(optional = false)
    @Column(name = "CD_CIDA")
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "seq_AM_TB_CIDA")
    @SequenceGenerator(name="seq_AM_TB_CIDA", sequenceName = "seq_AM_TB_CIDA")
    private Integer cdCida;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 40)
    @Column(name = "NM_CIDA")
    private String nmCida;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cdCida")
    private Collection<AmTbBair> amTbBairCollection;
    @JoinColumn(name = "CD_UF", referencedColumnName = "CD_UF")
    @ManyToOne(optional = false)
    private AmTbUf cdUf;

    public AmTbCida() {
    }

    public AmTbCida(Integer cdCida) {
        this.cdCida = cdCida;
    }

    public AmTbCida(Integer cdCida, String nmCida) {
        this.cdCida = cdCida;
        this.nmCida = nmCida;
    }

    public Integer getCdCida() {
        return cdCida;
    }

    public void setCdCida(Integer cdCida) {
        this.cdCida = cdCida;
    }

    public String getNmCida() {
        return nmCida;
    }

    public void setNmCida(String nmCida) {
        this.nmCida = nmCida;
    }

    @XmlTransient
    public Collection<AmTbBair> getAmTbBairCollection() {
        return amTbBairCollection;
    }

    public void setAmTbBairCollection(Collection<AmTbBair> amTbBairCollection) {
        this.amTbBairCollection = amTbBairCollection;
    }

    public AmTbUf getCdUf() {
        return cdUf;
    }

    public void setCdUf(AmTbUf cdUf) {
        this.cdUf = cdUf;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cdCida != null ? cdCida.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AmTbCida)) {
            return false;
        }
        AmTbCida other = (AmTbCida) object;
        if ((this.cdCida == null && other.cdCida != null) || (this.cdCida != null && !this.cdCida.equals(other.cdCida))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.agenda.model.entity.AmTbCida[ cdCida=" + cdCida + " ]";
    }
    
}
